// 自定义methods
export function customMethod(methods) {
  let customMethods = {};
  (methods || []).forEach((method) => {
    if (typeof method == 'object') {
      customMethods = {
        ...customMethods,
        ...method,
      };
    } else if (typeof method == 'string' && method) {
      try {
        customMethods = {
          ...customMethods,
          ...require('@/common/methods/' + method),
        };
      } catch (e) {
        customMethods = {
          ...customMethods,
          ...require('../methods/' + method),
        };
      }
    }
  });
  
  return customMethods;
}

export function customFilter(filters){
  let customFilters = {};
  (filters || []).forEach((filter) => {
    if (typeof filter == 'object') {
      customFilters = {
        ...customFilters,
        ...filter,
      };
    } else if (typeof filter == 'string' && filter) {
      try {
        customFilters = {
          ...customFilters,
          ...require('@/common/filters/' + filter),
        };
      } catch (e) {
        customFilters = {
          ...customFilters,
          ...require('../filters/' + filter),
        };
      }
    }
  });
  
  return customFilters;
}

export function customComputed(computeds){
  let customComputeds = {};
  (computeds || []).forEach((computed) => {
    if (typeof computed == 'object') {
      customComputeds = {
        ...customComputeds,
        ...computed,
      };
    } else if (typeof computed == 'string' && computed) {
      try {
        customComputeds = {
          ...customComputeds,
          ...require('@/common/computed/' + computed),
        };
      } catch (e) {
        customComputeds = {
          ...customComputeds,
          ...require('../filters/' + computed),
        };
      }
    }
  });
  
  return customComputeds;
}